/* Default theme (dark) */
:root {
  --background: #000000;
  --foreground: #e5e5e5;
  --primary: #8b5cf6;
  --primary-foreground: #ffffff;
  --secondary: #2d2d2d;
  --secondary-foreground: #e5e5e5;
  --muted: #2d2d2d;
  --muted-foreground: #a1a1aa;
  --accent: #2d2d2d;
  --accent-foreground: #e5e5e5;
  --border: #3f3f46;
  --border-hover: #52525b;
  --input: #3f3f46;
  --card: #1e1e1e;
  --card-foreground: #e5e5e5;
  --card-hover: #2d2d2d;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-hover: rgba(0, 0, 0, 0.4);
  --radius: 0.5rem;
  --transition: all 0.3s ease-in-out;
  --star-color: #fbbf24;
}

/* Light theme override */
.light-theme {
  --background: #ffffff;
  --foreground: #333333;
  --primary: #7c3aed;
  --primary-foreground: #ffffff;
  --secondary: #f3f4f6;
  --secondary-foreground: #1f2937;
  --muted: #f3f4f6;
  --muted-foreground: #6b7280;
  --accent: #f3f4f6;
  --accent-foreground: #1f2937;
  --border: #e5e7eb;
  --border-hover: #d1d5db;
  --input: #e5e7eb;
  --card: #ffffff;
  --card-foreground: #333333;
  --card-hover: #f9fafb;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
}

/* Ensure theme transitions work smoothly */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.8;
  font-size: 16px;
  transition: background-color 0.3s, color 0.3s;
}

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: color 0.2s;
}

a:hover {
  color: var(--primary-foreground);
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
}

/* Badge Styles */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.badge-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Webtoon Grid */
.popular-section,
.new-releases-section {
  padding: 2rem 0;
  margin-top: 1.5rem;
}

.popular-section {
  margin-top: 2rem;
}

.webtoon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.new-releases-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.webtoon-card {
  overflow: hidden;
  border-radius: var(--radius);
  background-color: var(--card);
  box-shadow: 0 2px 10px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.webtoon-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px var(--shadow-hover);
}

.webtoon-card a {
  color: var(--card-foreground);
}

.webtoon-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
}

.webtoon-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.webtoon-card:hover .webtoon-cover img {
  transform: scale(1.05);
}

.rating-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background-color: rgba(255, 255, 255, 0.8);
  color: #333;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
}

.webtoon-info {
  padding: 0.75rem;
}

.webtoon-info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.webtoon-info p {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin-top: 2rem;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: var(--radius);
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 0.75rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover {
  background-color: var(--muted);
}

.pagination-btn-active {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.pagination-btn-active:hover {
  background-color: var(--primary);
  opacity: 0.9;
}

/* Series Card */
.series-card {
  display: flex;
  flex-direction: column;
  background-color: var(--card);
  border: 1px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out, border-color 0.3s ease-in-out, background-color 0.3s ease-in-out;
  cursor: pointer;
  height: 100%;
}

.series-card:hover {
  box-shadow: 0 15px 25px var(--shadow-hover);
  transform: translateY(-10px);
  border-color: transparent;
  background-color: var(--card-hover);
}

.series-card:focus-within {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

.series-image {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
}

.series-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  display: block;
}

.series-card:hover .series-image img {
  transform: scale(1.1);
}

.series-info {
  padding: 0.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.series-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.25rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: var(--transition);
}

.series-card:hover .series-title,
.series-card:hover .series-title a {
  color: var(--primary);
}

.series-title a {
  color: var(--foreground);
  text-decoration: none;
  transition: color 0.2s ease;
}

.series-title a:hover {
  color: var(--primary);
}

.series-description {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  flex: 1;
  text-overflow: ellipsis;
}

.series-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

.series-author,
.series-rating {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  transition: var(--transition);
}

.series-rating .fa-star {
  color: var(--star-color);
}

.series-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.series-stats span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.series-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: auto;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius);
  font-size: 0.625rem;
  font-weight: var(--font-weight-medium);
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.badge:hover {
  background-color: var(--secondary-hover);
  border-color: var(--border-hover);
}

.badge-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}


/* Media Queries - Mobile First Responsive Design */
@media (max-width: 479px) {
  .container {
    padding: 0 0.75rem;
  }

  .section-header h2 {
    font-size: 1.25rem;
  }
}

@media (min-width: 768px) {
  .webtoon-grid,
  .new-releases-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .section-header h2 {
    font-size: 1.5rem;
  }

  .popular-section {
    margin-top: 3rem;
  }

  .series-info {
    padding: 0.75rem;
  }

  .series-title {
    font-size: 1rem;
  }

  .series-description {
    font-size: 0.875rem;
  }

  .series-author,
  .series-rating {
    font-size: 0.875rem;
  }

  .series-stats {
    font-size: 0.875rem;
  }

  .badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 1024px) {
  .webtoon-grid,
  .new-releases-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .popular-section {
    margin-top: 4rem;
  }

  .series-info {
    padding: 1rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .webtoon-card:active {
    transform: translateY(-2px);
  }
}

@media (min-width: 1280px) {
  .popular-section .webtoon-grid {
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
  }
  
  .new-releases-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  .popular-section .webtoon-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .new-releases-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .popular-section .webtoon-grid,
  .new-releases-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 640px) and (max-width: 767px) {
  .popular-section .webtoon-grid,
  .new-releases-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }
}

@media (max-width: 639px) {
  .popular-section .webtoon-grid,
  .new-releases-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}
